﻿using Newtonsoft.Json;
using SkypeBot.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace SkypeBot.Core
{

      public class Taras : IMessageHandler
        {

          private Article mobjMarasJokesList { get; set; }

          [MessageAttribute(@"^!taras|Тарик$|Тарас$|Марас$")]
          public Responce ChuckNorrisJoke(Message message, string name)
            {
                if (mobjMarasJokesList == null)
                {
                    mobjMarasJokesList = new Article();
                    mobjMarasJokesList.Articles = RSSParser.GetRecords("http://www.chucknorrisfacts.ru/rss", Encoding.GetEncoding("windows-1251"));
                }
                mobjMarasJokesList.Articles.Shuffle();


                return new Responce(ProcessString(mobjMarasJokesList.Articles[0].Description));
                
            }

            private string ProcessString(string mstrInputString)
            {
                mstrInputString = mstrInputString.Replace("Чак", "Марас");
                mstrInputString = mstrInputString.Replace("Норрису", "Носатому");
                mstrInputString = mstrInputString.Replace("Норриса", "Носатого");
                mstrInputString = mstrInputString.Replace("Норрисом", "Носатым");
                mstrInputString = mstrInputString.Replace("Норрис", "Носатый");
                mstrInputString = mstrInputString.Replace("&quot;", "\"");
                
                return mstrInputString;
            }

        }
    
}
